﻿///***************************************************************
/// 시  스  템 : Updms.Dvd
/// 단위시스템 : DVD
/// 계      층 : Presentation Layer
/// 프로그램명 : Dvd2010r
/// 파  일  명 : Dvd2010r.aspx.cs
/// 설      명 : DVD요약챠트
///***************************************************************
/// 수정ID 일자       이름     내용
///---------------------------------------------------------------
/// CH001  2008-08-13 송시명   최초 작성
///***************************************************************
using System;
using System.Data;
using System.Web.UI;

using SMFramework.Data;
using SMFramework.Utility;

using Base.Dac;
using Updms.Dvd.Exe;


namespace Updms.Dvd
{
	public partial class Dvd2010r : Updms.Common.BaseClass.PageBase
	{
		#region 전역영역

		//프로그램상수
		public static readonly string PID = "Dvd2010r";
		public static readonly string gs_path_info = "/updms/Dvd/" + PID + ".aspx";

		Global global = new Global();

		//메뉴 선택값
		protected string gs_sm = "";

		#endregion

		#region Page_Load, OnPageLoad

		protected void Page_Load(object sender, EventArgs e)
		{
			SetInit();
			if (!Page.IsPostBack)
			{
				// 최초 화면 로딩시 처리해야 할 부분
				SetLiterals(global.GetLabelInfoByPgmId(PID, LANG_SET));
				SearchProcess();
			}
		}		

		#endregion

		#region InitializeComponent

		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
			this.PreRender += new System.EventHandler(this.Page_PreRender);
		}

		#endregion	

		#region SetInit

		//초기값설정
		private void SetInit()
		{
			lbl_search_flag.Text = "INIT";
			
			gs_sm = (Request.QueryString["sm"] == null || Request.QueryString["sm"].Trim().Length != 7)
					? global.GetDirDepth(PID) : Request.QueryString["sm"].ToString();
		}

		#endregion

		#region 챠트 (DrawTotalSummaryList, DrawCategoryListByDiv, SearchProcess)

		//조회
		private void DrawTotalSummaryList()
		{
			DataSet lo_ds = new DataSet();	
		
			using (Dvd2010r_NT _Dvd2010r_NT = new Dvd2010r_NT())
			{
				lo_ds.Merge(_Dvd2010r_NT.GetTotalSummaryList());
			}
			int li_count = DataSetUtil.GetRowCount(lo_ds, "UPDMS_DVD_REPORT");

			//초기화
			chart_actress.Data.Clear();
			chart_rate.Data.Clear();
			chart_studio.Data.Clear();			

			for (int i = 0; i < li_count; i++)
			{
				switch (DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Div"))
				{
					case "Actress":	//배우별
						chart_actress.Data[0, i] = DataSetUtil.GetFldInt(lo_ds, "UPDMS_DVD_REPORT", i, "Cnt");
						chart_actress.AxisX.Labels[i] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Nm");
						chart_actress.Points[i].Link.OnClick
							= "javascript:goDvdDetailPage('1','" + DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Nm") + "','" + DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Nm") + "');";
						break;
					case "Rate":	//평점별
						chart_rate.Data[0, i] = DataSetUtil.GetFldInt(lo_ds, "UPDMS_DVD_REPORT", i, "Cnt");
						chart_rate.AxisX.Labels[i] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Nm");
						chart_rate.Points[i].Link.OnClick
							= "javascript:goDvdDetailPage('2','" + DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Nm") + "','" + DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Nm") + "');";
						break;
					case "Studio":	//스튜디오별
						chart_studio.Data[0, i] = DataSetUtil.GetFldInt(lo_ds, "UPDMS_DVD_REPORT", i, "Cnt");
						chart_studio.AxisX.Labels[i] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Nm");
						chart_studio.Points[i].Link.OnClick
							= "javascript:goDvdDetailPage('3','" + DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Cd") + "','" + DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Nm") + "');";
						break;
				}				
			}
		}


		//카테고리별 챠트
		private void DrawCategoryListByDiv()
		{
			DataSet lo_ds = new DataSet();
			DataPack lo_dp = new DataPack();

			lo_dp.AddProperty("ls_lang_set", typeof(string), LANG_SET);

			using (Dvd2010r_NT _Dvd2010r_NT = new Dvd2010r_NT())
			{
				lo_ds.Merge(_Dvd2010r_NT.GetCategoryListByDiv(lo_dp));
			}
			int li_count = DataSetUtil.GetRowCount(lo_ds, "UPDMS_DVD_REPORT");

			//초기화
			chart_contents.Data.Clear();
			chart_look.Data.Clear();
			chart_costume.Data.Clear();
			chart_character.Data.Clear();

			for (int i = 0; i < li_count; i++)
			{
				switch (DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Div"))
				{
					case "AC":	//내용
						chart_contents.Data[0, i] = DataSetUtil.GetFldInt(lo_ds, "UPDMS_DVD_REPORT", i, "Cnt");
						chart_contents.AxisX.Labels[i] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Nm");
						break;
					case "AD":	//외모
						chart_look.Data[0, i - 7] = DataSetUtil.GetFldInt(lo_ds, "UPDMS_DVD_REPORT", i, "Cnt");
						chart_look.AxisX.Labels[i - 7] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Nm");
						break;
					case "AE":	//복장
						chart_costume.Data[0, i - 14] = DataSetUtil.GetFldInt(lo_ds, "UPDMS_DVD_REPORT", i, "Cnt");
						chart_costume.AxisX.Labels[i - 14] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Nm");
						break;
					case "AF":	//특징
						chart_character.Data[0, i - 21] = DataSetUtil.GetFldInt(lo_ds, "UPDMS_DVD_REPORT", i, "Cnt");
						chart_character.AxisX.Labels[i - 21] = DataSetUtil.GetFldStr(lo_ds, "UPDMS_DVD_REPORT", i, "Nm");
						break;
				}
			}
		}
		
		
		//검색
		private void SearchProcess()
		{
			lbl_search_flag.Text = "SEARCH";
			
			DrawTotalSummaryList();
			DrawCategoryListByDiv();
		}

		#endregion

		#region Page_PreRender, ChangePageMode

		// Page_PreRender
		private void Page_PreRender(object sender, System.EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				using (AccessCheck access = new AccessCheck())
				{
					//접근권한 체크
					if (!access.CheckPgmAccessGrant(PID, USER_ID, ACCESS_LOG_INFO))
					{
						Response.Redirect(URL_NO_AUTHORITY_REDIRECT_BASE);	//사용자의 권한은 요청하신 페이지를 볼 수 없습니다
					}
				}
			}
		}		

		#endregion

		#region 버튼이벤트

		//검색
		protected void ibtn_chart_Click(object sender, EventArgs e)
		{
			SearchProcess();
		}
		
		#endregion


	}
}
